import ShopgradeParam from './ShopgradeParam'
import * as actions from '../../../redux/actions/TypeParamAction'
import * as settingAction from '../../../redux/actions/SettingAction'
import { SimpleType, StoreState } from '../../../redux/Types'
import { Dispatch } from 'redux'
import { connect } from 'react-redux'


export function mapStateToProps({typeParam: { data, loading }, setting: { minCategorys, erpShops } }: StoreState) {
  return {
    data,
    loading,
    minCategorys,
    erpShops
  }
}
export function mapDispatchToProps(dispatch: Dispatch<actions.TypeParamAction | settingAction.SettingAction>) {
  return {
    getErpShops: () => {
      dispatch(settingAction.initErpShop())
    },
    getMinCategory: () => {
      dispatch(settingAction.initMinCategory())
    },
    list: (data: SimpleType, page: any) => {
      dispatch(actions.page(page))
      dispatch(actions.GetTypeParamList(data, 5))
    },
    record: (record: any) => {
      dispatch(actions.recordTypeParam(record))
    },
    clear: () => {
      dispatch(actions.clearTypeParam())
    }
  }
}
export default connect(mapStateToProps, mapDispatchToProps)(ShopgradeParam)